package com.hujifang.elasticsearch.service;

import com.hujifang.elasticsearch.model.*;
import com.hujifang.elasticsearch.moudle.Result;

import java.util.List;

/**
 * <title>ElasticSearch接口</title>
 * Created by Hurricane.Hu on 2015/8/12.
 */
public interface ElasticSearchService {
    /**
     * 创建空的索引库
     * @param esIndex
     * @return
     */
    Result createIndex(EsIndex esIndex) throws Exception;

    /**
     * 删除索引库
     * @param esIndex
     */
    Result deleteIndex(EsIndex esIndex) throws Exception;

    /**
     * 创建索引库类型
     * @param esType
     * @throws Exception
     */
    Result createType(EsType esType) throws Exception;

    /**
     *删除索引库类型
     * @param esType
     */
    Result deleteType(EsType esType) throws Exception;

    /**
     * 是否存在索引
     * @param esIndex
     * @return
     * @throws Exception
     */
    Result isExistsIndices(EsIndex esIndex) throws Exception;

    /**
     * 是否存在索引库类型
     * @param esType
     * @throws Exception
     */
    Result isExistsType(EsType esType) throws Exception;

    /**
     * 删除Mapping
     * @param esType
     */
    Result deleteMapping(EsType esType) throws Exception;
    /**
     * 添加文档
     * @param esDocument 文档
     */
    Result addDocument(EsDocument esDocument) throws Exception;

    /**
     * 批量添加文档
     * @param esDocumentList 为文档集合
     * @return
     */
    Result batchAddDocument(List<EsDocument> esDocumentList) throws Exception;

    /**
     * 添加关键词
     * @param esDocumentList
     * @throws Exception
     */
    Result addKeywordDocument(List<EsDocument> esDocumentList) throws Exception;

    /**
     * 更新文档
     * @param esDocument
     * @throws Exception
     */
    Result updateDocument(EsDocument esDocument) throws Exception;

    /**
     * 更新文档
     * @param esDocumentList
     * @throws Exception
     */
    Result batchUpdateDocument(List<EsDocument> esDocumentList) throws Exception;

    /**
     * 删除文档
     * @param esDocument
     * @return
     */
    Result deleteDocument(EsDocument esDocument) throws Exception;

    /**
     * 批量删除文档
     * @param esDocumentList 文档集合
     * @return
     */
    Result batchDeleteDocument(List<EsDocument> esDocumentList) throws Exception;

    /**
     * 执行搜索
     * @param esSearch
     * @return
     */
    Result search(EsSearch esSearch) throws Exception;

    Result addJDBCRiverConfig(EsJDBCRiverConfig jdbcRiverConfig, String riverName) throws Exception;

    /**
     * 执行搜索
     * @param esAggregations
     * @return
     */
    Result search(EsAggregation esAggregations) throws Exception;

    /**
     * 搜索建议，自动补全搜索结结果
     * @param esSearch
     */
    Result searchCompletionSuggest(EsSearch esSearch) throws Exception;

    /**
     * 关键词建议，支持原关键词、全拼、首拼，需要收集关键词
     * @param esSearch
     */
    Result searchKeywordSuggest(EsSearch esSearch) throws Exception;
}
